//
//  MCDiscountPayHeadView.swift
//  StoreManage
//
//  Created by MC on 2017/12/19.
//  Copyright © 2017年 MC. All rights reserved.
//

import UIKit

class MCDiscountPayHeadView: UIView {
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        backgroundColor = UIColor.MCGray_light
        self.frame = CGRect.init(x: 0, y: 0, width: 0, height: 130)
        setUpSubViews()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func setUpSubViews() {
        self.addSubview(yesterdayView)
        yesterdayView.snp.remakeConstraints { (make) ->Void in
            make.left.equalTo(self)
            make.top.equalTo(self).offset(5)
            make.bottom.equalTo(self).offset(-5)
            make.width.equalTo(MCScreenWidth/2-1)
            
        }
        
        self.addSubview(totalView)
        totalView.snp.remakeConstraints { (make) ->Void in
            make.right.equalTo(self)
            make.top.equalTo(self).offset(5)
            make.bottom.equalTo(self).offset(-5)
            make.width.equalTo(MCScreenWidth/2-1)
        }
    }
    
    
    lazy var yesterdayView: MCDiscountPayHeadItemView = {
        let view = MCDiscountPayHeadItemView()
        view.iconImageView.image = #imageLiteral(resourceName: "DiscountPay_oneline")
        view.yesterdayLabel.text = "昨日： ¥0"
        view.totalLabel.text = "总计： ¥0"
        return view
    }()
    
    lazy var totalView: MCDiscountPayHeadItemView = {
        let view = MCDiscountPayHeadItemView()
        view.iconImageView.image = #imageLiteral(resourceName: "DiscountPay_offline")
        view.yesterdayLabel.text = "昨日： ¥0"
        view.totalLabel.text = "总计： ¥0"
        return view
    }()
}


class MCDiscountPayHeadItemView: UIView {
    override init(frame: CGRect) {
        super.init(frame: frame)
        backgroundColor = UIColor.white
        setUpSubViews()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func setUpSubViews() {
        
        self.addSubview(iconImageView)
        iconImageView.snp.updateConstraints { (make) -> Void in
            make.centerX.equalTo(self)
            make.top.equalTo(self).offset(10)
        }
        
        
        self.addSubview(yesterdayLabel)
        yesterdayLabel.snp.remakeConstraints { (make) ->Void in
            make.centerX.equalTo(self)
            make.top.equalTo(iconImageView.snp.bottom).offset(20)
        }
        
        self.addSubview(totalLabel)
        totalLabel.snp.remakeConstraints { (make) ->Void in
            make.centerX.equalTo(self)
            make.top.equalTo(yesterdayLabel.snp.bottom).offset(10)
        }
    }


    public lazy var iconImageView: UIImageView = {
        let iconImageView = UIImageView.init()
        
        return iconImageView
    }()
    
    public lazy var yesterdayLabel: UILabel = {
        let label = UILabel.init()
        label.font = MCFont(14)
        label.textColor = UIColor.MCBlack
        return label
    }()
    
    public lazy var totalLabel: UILabel = {
        let label = UILabel.init()
        label.font = MCFont(14)
        label.textColor = UIColor.MCBlack
        return label
    }()

}

